﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace scmsByAspdNet.cotro.teacher {
  /// <summary>
  /// updateTeacherInfo 的摘要说明
  /// </summary>
  public class updateTeacherInfo : IHttpHandler {

    public void ProcessRequest(HttpContext context) {
      context.Response.ContentType = "text/plain";

      //获取数据
      string tea_id = context.Request["tea_id"];
      string name = context.Request["name"];
      string faculty = context.Request["faculty"];
      string intro = context.Request["intro"];

      //更新操作
      SqlConnection conn = new SqlConnection("Data Source=106.54.69.143;database=scms;uid=sa;pwd=Aspdotnet666");
      conn.Open();

      SqlCommand sql_u = new SqlCommand($"update sc_teacher set name='{name}',faculty='{faculty}',intro='{intro}' where id={tea_id}", conn);
      int res = sql_u.ExecuteNonQuery();
      conn.Close();
      //返回数据
      context.Response.StatusCode = 200;
      context.Response.Write($"{{\"line\":{res}}}");
    }

    public bool IsReusable {
      get {
        return false;
      }
    }
  }
}